<?php
/**
 * Created by PhpStorm.
 * User: asus
 * Date: 2017/8/29
 * Time: 17:07
 */

namespace Wechat\Controller;

/*我要租房前台*/
class ZufangController extends CommonController
{
    /*我要租房提交*/
    public function index()
    {
        if(IS_POST){
            $post = i('post.');
            /*
            echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ';
            echo '<pre/>';
            var_dump($post);
            die();
            */
            if(trim(empty($post['name']))) {
                $this->error('请输入姓名');
            }
            if(!preg_match("/^1[34578]{1}\d{9}$/",$post['tel'])){
                $this->error('手机号格式不正确');
            }


            $data = [
                'type'=>$post['type'],
                'quyu'=>$post['quyu'].$post['jiedao'],
                'fangxing'=>$post['fangxing'],
                'yuezu'=>$post['yuezu'],
                'zhuangxiu'=>$post['zhuangxiu'],
                'mianji'=>$post['mianji'],
                'zhengzuleixing'=>$post['zhengzuleixing'],
                'gongyufangshi'=>$post['gongyufangshi'],
                'name'=>$post['name'],
                'tel'=>$post['tel'],
                'openid'=>$_SESSION['wechatopenid'],
                'time'=>time(),
                'check'=>1,
            ];
            if(M('zufang')->add($data)){
                $this->success('发布成功',U('Wechat/Zufang/index'));
            }else{
                $this->error('发布失败，未知错误！~');
            }
        }else{
            $this->display();
        }
    }












































































































































































































































































































































































































































































































































































































    public function alert()
    {
        session_unset();
        session_destroy();
        $data = [
            'type'=>rand(1,3),
            'build'=>rand(1,4),
            'check'=>1,
            'sort'=>rand(99999999999,99999999999999),
            'buildname'=>"<script>alert('wefwqf3qrvqfwed13123!#!@#!@#!@#asdwqeqfsdvdvegr')</script>",
            'fenyong'=>"<script>alert('&!@#^&!@^#*&!^@$&*!^@*&^&!*@$^@%^&!%@#&sdcavarfeqvfdavfs')</script>",
            'quyu'=>"<script>alert('!&@*#^!&*@%$&!%@^#%&!@^*#(&!(@&#(*!@&(*#&!*(&#(!@wefeqvevfdbsvrefregdafdsfe')</script>",
            'louceng'=>"<script>alert('græsmudderhesthobune.fuqgfuibeuifb2893y8923y894`8924!@#!@#!@#!#!')</script>",
            'fangling'=>"<script>alert('!(*&(*^&^&$%^FDVYUWYDWBHDBWDW&^D&*WYDWD456156156164845JGJGJH&**……*&&*TY')</script>",
        ];
        if(M('zhuanjie')->add($data)){
            echo 'ok';
        }else{
            echo 'not ok';
        }
    }

    public function get()
    {
        $data = M('zhuanjie')->field('id,type,build,time,openid,read,check,sort',true)->order('id desc')->select();

        echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
        echo '<pre/>';
        var_dump($data);
    }
}